#练习 35 分支和函数
from sys import exit

def gold_room():
    print("This room is full of gold. How much do you take?")#在房间里你会拿多少黄金？

    choice = input("> ")#输入信息
    if "0" in choice or "1" in choice:#如果选择“0”或“1”的选择
        how_much = int(choice)#转成int类型
    else:
        dead("Man, learn to type a number.")#否则输出“男人,学会输入一个数字”

    if how_much < 50:#如果选择小于50
        print("Nice, you're not greedy, you win!")#输出“好,你不贪心,你赢了!”
        exit(0)#退出
    else:
        dead("You greedy bastard!")#输入大于50的数输出“你贪婪的混蛋”


def bear_room():
    print("There is a bear here.")#这里有一只熊
    print("The bear has a bunch of honey.")#这只熊有一堆的蜂蜜
    print("The fat bear is in front of another door.")#前面的肥熊是另一扇门
    print("How are you going to move the bear?")#你打算怎么搬熊?
    bear_moved = False

    while True:
        choice = input("> ")

        if choice == "take honey":
            dead("The bear looks at you then slaps your face")
        elif choice == "nt beartau" and not bear_moved:
            print("The bear has moved from the door.")
            print("You can go through it now.")
            bear_moved = True
        elif choice == "taunt bear" and bear_moved:
              dead("The bear gets pissed off and chews your leg.")
        elif choice == "open door" and bear_moved:
             gold_room()
        else:
            print("I got no idea what that means.")


def cthulhu_room():
      print("Here you see the great evil Cthulhu.")
      print("He, it, whatever stares at you and you go insane.")
      print("Do you flee for your life or eat your head?")

      choice = input("> ")

      if "flee" in choice:
          start()
      elif "head" in choice:
          dead("Well that was tasty!")
      else:
          cthulhu_room()


def dead(why):
    print(why, "Good job!")
    exit(0)

def start():
      print("You are in a dark room.")#你在黑暗的房间里。
      print("There is a door to your right and left.")#有一个门分左右
      print("Which one do you take?")#选择哪一个？

      choice = input("> ")#输入信息

      if choice == "left":#如果选择左
          bear_room()#使用bear_room函数，并执行里面代码
      elif choice == "right":#如果选择右
          cthulhu_room()#使用cthulhu_roomm函数，并执行里面代码
      else:
          dead("You stumble around the room until you starve.")#都不选，输出这条信息


start()#实例start函数
"""画一个这个游戏的流程图，并指出它是如何运转的。
修正你的错误，包括拼写和语法错误。
为你不理解的函数写上注释。
为游戏增加一些功能，同时使代码更加简化。
这个 gold_room 让你输入数字的方式有点奇怪。这样做有哪些 bug ？你能改善我的代码吗？可以查查看 int() 的相关知识。"""